package com.deer.wms.ware.task.model.SO;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import com.deer.wms.inventory.model.Inventory.InventoryDto;
import lombok.Data;

/**
 * 库存导出模型
 * @author : wei
 * @since : 2022-09-28 09:50:23
 **/
@ContentRowHeight(20)
@HeadRowHeight(25)
@ColumnWidth(25)
@Data
public class SoExportModel {
    @ExcelProperty(value = "行号" ,index = 0)
    private String lineNo;

    @ExcelProperty(value = "物料编码" ,index = 1)
    private String itemCode;

    @ExcelProperty(value = "物料名称" ,index = 2)
    private String itemName;

    @ExcelProperty(value = "状态" ,index = 3)
    private String state;

    @ExcelProperty(value = "缺料数量" ,index = 4)
    private Double quantity;

    @ExcelProperty(value = "总发货数量" ,index = 5)
    private Double deliveryQuantity;

    @ExcelProperty(value = "本次发货数量" ,index = 6)
    private Double currentQuantity;

    public SoExportModel(SoDetail soDetail) {
        this.lineNo = soDetail.getDetailNo().substring(soDetail.getDetailNo().lastIndexOf('-') + 1);
        switch (soDetail.getState()) {
            case 0:
                this.state = "新建";
                break;
            case 4:
                this.state = "执行中";
                break;
            case 8:
                this.state = "完成";
                break;
            case 9:
                this.state = "手工关闭";
                break;
            default:
                throw new IllegalStateException("Unexpected value: " + soDetail.getState());
        }
        this.itemCode = soDetail.getItemCode();
        this.itemName = soDetail.getItemName();
        this.quantity = soDetail.getOrderQuantity();
        this.deliveryQuantity = soDetail.getDeliveryQuantity();
        this.currentQuantity = soDetail.getDeliveryQuantity() - soDetail.getQtyTrans();
    }
}
